package state;

import java.awt.*;
import java.awt.event.*;

import javax.swing.ImageIcon;

import sprite.Button;

import data.GameView;


public class IntroState extends AbstractGameState
{
	
	private Button startButton = new Button();
	private Button exitButton = new Button();
	
    public IntroState(GameView view)
    {
        super(view);
        startButton.setImage(new ImageIcon("images/Orange1 (Custom).png").getImage());
        startButton.setPosition(500-128, 575/2-128);
        exitButton.setImage(new ImageIcon("images/Orange1 (Custom) (2).png").getImage());
        exitButton.setPosition(500-128, 575/2+10);
    }
    
    public void drawOn(Graphics g)
    {
        Rectangle bounds = this.getView().getBounds();
        g.drawImage(new ImageIcon("images/IMAG0083.jpg").getImage(), 0, 0, bounds.width, bounds.height, null);
        
        this.startButton.drawOn(g);
        this.exitButton.drawOn(g);
    }
            
    public void handleKeyPressed(int keyCode)
    {
        if (keyCode == KeyEvent.VK_ENTER) {
            this.getView().setState(new PlayState(this.getView()));
        }
        else if (keyCode == KeyEvent.VK_ESCAPE) {
        	System.exit(0);
        }
    }
    public void handleMousePressed(MouseEvent e, int mouseX, int mouseY) {
    	if (startButton.getRect().contains(new Point(mouseX, mouseY))) {
    		this.getView().setState(new PlayState(this.getView()));
    	}
    	else if (exitButton.getRect().contains(new Point(mouseX, mouseY))) {
    		System.exit(0);
    	}
    }
}